/*
 * Point
 * 
 * initial implementation : 28.8.2007
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using System;
//using System.Collections.Generic;
//using System.Text;
using Petra.Gis.Geometry.Support;


namespace Petra.Gis.Geometry
{
  /// <summary>
  /// point geometry is simple 3d gis point object
  /// given by its Origin
  /// </summary>
  //public class Point : pointGeometryBase
  public class Point : GeometryBase, ICoordinate
  {
    protected double _rotation = 0;
    protected CoordinateList _coordList;



    public Point()
    {
      _valid = false;
    }



    /// <summary>
    /// Creates new point from given coordinates
    /// </summary>
    /// <param name="X">point x as <c>double</c> </param>
    /// <param name="Y">point y</param>
    /// <param name="Z">point z</param>
    public Point(double X, double Y, double Z)
    {

      CoordinateList Coords = new CoordinateList(Dimension.dim3D, X, Y, Z);
      _coordList = Coords;
      _valid = true;
    }




    public virtual CoordinateList coordList
    {
      get { return _coordList; }
      set 
      {
        if(value != null)
          if (value.Count != 1)
            throw new ArgumentException("Point coordlist must contain only one point");

        _coordList = value;
      }
    }




    internal override BoundingBox getEnvelope()
    {
      return _coordList.getEnvelope();
    }



    public virtual double X { get { return _coordList[0].X; } set { _coordList[0].X = value; } }
    public virtual double Y { get { return _coordList[0].Y; } set { _coordList[0].Y = value; } }
    public virtual double Z { get { return _coordList[0].Z; } set { _coordList[0].Z = value; } }



    public virtual double lon { get { return _coordList[0].X; } set { _coordList[0].X = value; } }
    public virtual double lat { get { return _coordList[0].Y; } set { _coordList[0].Y = value; } }



    /// <summary>
    /// get/set rotation angle in decimal degrees of current point
    /// This is equvalent to M (measure) value known from ESRI suite
    /// </summary>
    public virtual double Rotation
    {
      get { return _rotation; }
      set { _rotation = value; }
    }




    /// <summary>
    /// compare this coordinate values to another in desired dimension
    /// </summary>
    /// <param name="AnotherPoint">another coordinate to compare to</param>
    /// <param name="dimension">compare dimension</param>
    /// <returns>true when coordinate values are same in given dimension, false otherwise</returns>
    public bool Equals(ICoordinate AnotherPoint, Dimension dimension)
    {
      bool isSame = false;
      if (this.X == AnotherPoint.X && this.Y == AnotherPoint.Y)
        isSame = true;
      if (dimension == Dimension.dim3D && (this.Z != AnotherPoint.Z))
        isSame = false;
      return isSame;
    }

  }

}
